package cn.tedu.imop.basic.dao.repository.impl;

import cn.tedu.imop.basic.dao.mapper.BusinessMapper;
import cn.tedu.imop.basic.dao.repository.BusinessRepository;
import cn.tedu.imop.basic.entity.Business;
import cn.tedu.imop.common.context.PageContext;
import cn.tedu.imop.common.pojo.PageData;
import cn.tedu.imop.common.utils.PageInfoToPageDataConverter;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.List;


@Repository
public class BusinessRepositoryImpl implements BusinessRepository {
    private BusinessMapper businessMapper;
    public BusinessRepositoryImpl(BusinessMapper businessMapper) {
        this.businessMapper = businessMapper;
    }
    @Override
    public PageData<Business> selectBusinessList(Business bussiness) {
        PageContext.startPage();
        List<Business> list = businessMapper.selectList(bussiness);
        return PageInfoToPageDataConverter.convert(new PageInfo<>(list));
    }
    @Override
    public int insertBusiness(Business business) {
         businessMapper.insert(business);
         int rows= businessMapper.insertIntroduction(business);
         return rows;
    }

}
